import java.util.Stack;


public class RuleEnv {

	Stack<ControlElement> control ;
	Stack<String> stack ;
	Environment environment;
	
	public RuleEnv(Stack<ControlElement> control, Stack<String> stack, Environment environment){
		this.control = control;
		this.stack = stack;
		this.environment = environment;
	}
	
	public static void main(String[] args) {
		Stack<ControlElement> control = new Stack<ControlElement>();
		Stack<String> stack = new Stack<String>();
		Environment environment = new Environment();
		RuleEnv ruleEnv = new RuleEnv(control, stack, environment);

		// test1 
		control.push(new ControlElement("e:2"));
		stack.push("e:2");
		stack.push("<false>");
		System.out.println(ruleEnv.checkRule());
		//ruleOP.devide();
		//ruleOP.power();
		ruleEnv.applyRule();
		System.out.println("Control:"+ruleEnv.control + " Stack:" +ruleEnv.stack);
	}
	
	public void applyRule() {
		String returnValue = stack.pop();
		if (control.pop().content.equals(stack.pop())){
			stack.push(returnValue);
			environment.envLoaded.pop();
			environment.currentEnv = environment.envLoaded.peek();
		}else{
			System.out.println("RuleEnv: The two environments must match");
		}
	}

	public boolean checkRule() {
		if (control.peek().content.contains("e:"))
			return true;
		else
			return false;
	}

}
